<template>
	<view class="three" :data-theme="theme">
		<view class="header">
			<u-steps :current="num" :activeColor="bgColor">
				<u-steps-item :title="item.name" v-for="(item,index) in numList" :key="index">
				</u-steps-item>

			</u-steps>

		</view>
		<view class="BH5"></view>
		<view class="con">
			<!-- <img src="@/imgs/she.png"></img> -->
			<view class="tit">{{checkStatus[merchantData.checkStatus]}}</view>
			<view class="des text-gray" v-if="merchantData.checkStatus == 1">认证审核服务将在3个工作日内完成，请您耐心等待</view>
			<!-- <u-button class="tit bg_color" :color="bgColor" @click="loginClick">返回登录页</u-button> -->
			<button class="tit bg_color"
				style="font-weight: bold;border-radius: 16rpx;color: #FFF;padding: 20rpx;margin: 10rpx;"
				:color="bgColor" @click="loginClick">返回登录页</button>
		</view>
	</view>
</template>

<script>
	import {
		setThemeColor
	} from '../../../utils/setTheme';
	import {
		getMerTypeListApi,
		getMerCategoryListApi,
		applyEchoAPi
	} from '@/api/merchant.js';
	let app = getApp();
	export default {
		data() {
			return {
				bgColor: "#ffffff",
				theme: app.globalData.theme,
				numList: [{
					name: '提交资质'
				}, {
					name: '选择入驻方式'
				}, {
					name: '等待审核'
				}, ],
				num: 2,
				checkStatus: {
					1: "审核中",
					2: '审核成功',
					3: '审核拒绝'
				},
				merchantData: {},
			};
		},
		onLoad(options) {
			this.bgColor = setThemeColor()
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: this.bgColor,
			});
		},
		onShow() {
			// 回显数据 判断审核状态
			setTimeout(async () => {
				await this.applyEcho()
				if (this.merchantData.checkStatus == 2) { // 审核成功
					uni.showModal({
						title: '审核成功',
						content: '点击确认请您跳转到登录页重新登录',
						success: (res) => {
							uni.reLaunch({
								url: '/pages/login/login',
							});
						}
					})

				} else if (this.merchantData.checkStatus == 3) { // 审核拒绝
					uni.showModal({
						title: '审核拒绝',
						content: `原因：${this.merchantData.reason},请您重新申请。`,
						success: (res) => {
							uni.reLaunch({
								url: `/pages/certification/one/one`,
							});
						}
					})
				}
			}, 500)
		},
		methods: {
			// 返回登录页
			loginClick() {
				uni.navigateTo({
					url: '/pages/login/login',

				});
			},
			// 回显数据
			async applyEcho() {
				try {
					let result = await applyEchoAPi()
					if (result.code == 200) {
						if (result.data != null) {
							this.merchantData = result.data
						} else {
							this.merchantData.checkStatus == 1
						}
					}


				} catch (e) {
					//TODO handle the exception
					console.log(e)
				}
			},
		}
	}
</script>

<style lang="scss">
	::v-deep .u-steps-item__wrapper {
		background-color: #f5f5f5;
	}

	.header {
		margin-top: 20px;
	}

	.bg_color {
		@include main_bg_color(theme);
	}

	.text_color {
		@include main_color(theme)
	}

	.three {
		.BH5 {
			background-color: #F3F5F4;
			height: 4px;
		}

		.con {
			text-align: center;
			padding: 70px 20px 0;
			font-weight: 600;

			img {
				width: 80px;
			}

			.tit {
				font-size: 16px;
				padding: 20px 0;
			}

			.des {
				margin-bottom: 20px;
				line-height: 20px;
			}
		}
	}
</style>